package top.yxqz.spring.ioc.util;

import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.FactoryBean;
import top.yxqz.spring.ioc.pojo.User;

/**
 * @author: 余小小
 * @date: 2023/4/7
 * @description： 使用FactoryBean构建自己bean
 * <bean class="top.yxqz.spring.ioc.pojo.User"/>
 */
public class MyBeanFactory implements FactoryBean {
    @Override
    public Object getObject() throws Exception {
        User user = new User();
//        di操作
        user.setUseName("默认名称");
        user.setAge(0);
        user.setGender("男");
        return user;
    }

    @Override
    public Class<?> getObjectType() {
        return User.class;
    }

    @Override
    public boolean isSingleton() {
        return FactoryBean.super.isSingleton();
    }

}
